﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ipswitch
{
    public partial class Form_Main : Form
    {     


        private IPConfig[] ipConfig = new IPConfig[2];

        private IPConfig curIpConfig;
        public Form_Main()
        {
            InitializeComponent();

            GetIpConfig();
        }

        private void Form_Main_Load(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void GetIpConfig()
        {
            for (int i = 0; i < 2; i++)
            {
                ipConfig[i] = new IPConfig();
                ipConfig[i].ip = ConfigHelper.Get("ip" + i);
                ipConfig[i].mask = ConfigHelper.Get("mask" + i);
                ipConfig[i].gateway = ConfigHelper.Get("gateway" + i);
            }
        }

        private void ToolStripMenuItem_Setting_Click(object sender, EventArgs e)
        {
            Form_settings setting = new Form_settings();
            setting.ShowDialog();
            ipConfig = setting.ipconfig;
        }

        private void toolStripMenuItem_dhcp_Click(object sender, EventArgs e)
        {
            NetworkSet.SetDHCP();
        }

        private void iP1ToolStripMenuItem_static1_Click(object sender, EventArgs e)
        {
            curIpConfig = ipConfig[0];
            NetworkSet.SetStatic(ipConfig[0]);
        }

        private void iP2ToolStripMenuItem_static2_Click(object sender, EventArgs e)
        {
            curIpConfig = ipConfig[1];
            NetworkSet.SetStatic(ipConfig[1]);
        }

        private void ToolStripMenuItem_exit_Click(object sender, EventArgs e)
        {
            this.notifyIcon_main.Dispose();
            this.Dispose();
        }

        private void notifyIcon_main_Click(object sender, EventArgs e)
        {

        }
    }
}
